package controller.drawPanel;

import java.awt.event.MouseAdapter;

import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;

import controller.drawPanel.Interface.IDrawPanelController;

import model.drawPanel.DrawPanelModel;
import model.drawPanel.Interface.IDrawObserver;
import model.drawPanel.Interface.IDrawPanelModel;
import model.drawPanel.entitys.Entity;

public class DrawPanelController implements IDrawPanelController,MouseMoveListener , MouseListener ,KeyListener{
	private IDrawPanelModel dpm;
	private MouseMoveListener mml;
	private MouseListener ml;
	private KeyListener kl;
	public DrawPanelController(IDrawObserver drawObserver,int roomID){
		DrawPanelModel dp =new DrawPanelModel(drawObserver, roomID);
		dpm =(IDrawPanelModel) dp;
		mml = dp;
		ml = dp;
		kl = dp;
	}
	@Override
	public void setColor(Color color) {
		dpm.setColor(color);
		
	}

	@Override
	public void setTool(int tool) {
		dpm.setTool(tool);
		
	}

	@Override
	public void setLineStyle(int lineStyle) {
		dpm.setLineStyle(lineStyle);
		
	}

	@Override
	public void setFill(boolean hasFill) {
		dpm.setFill(hasFill);
		
	}

	@Override
	public void undo() {
		dpm.undo();
		
	}

	@Override
	public void redo() {
		dpm.redo();
		
	}

	@Override
	public void addPanel() {
		dpm.addPanel();
		
	}

	@Override
	public void deletePanel(int id) {
		dpm.deletePanel(id);
		
	}

	@Override
	public void choosePanle(int id) {
		dpm.choosePanle(id);
		
	}



	@Override
	public void addPicture(String filePath) {
		dpm.addPicture(filePath);
	}

	@Override
	public void save(String fileName) {
		dpm.save(fileName);
		
	}

	@Override
	public void requestAuthority() {
		dpm.requestAuthority();
		
	}

	@Override
	public void passAuthority(String id) {
		dpm.passAuthority(id);
		
	}

	@Override
	public void setCursor(int mouseStatus) {
		dpm.setCursor(mouseStatus);
		
	}

	@Override
	public void setTextInput(StyledText text) {
		dpm.setTextInput(text);
		
	}

	@Override
	public void setWidth(int width) {
		dpm.setWidth(width);

	}
	public void exite(){
		dpm.exite();
	}

	@Override
	public void draw(Display display, GC gc, int width, int height) {
		dpm.draw(display, gc, width, height);
		
	}
	@Override
	public void keyPressed(KeyEvent arg0) {
		kl.keyPressed(arg0);
		
	}
	@Override
	public void keyReleased(KeyEvent arg0) {
		kl.keyReleased(arg0);
		
	}
	@Override
	public void mouseDoubleClick(MouseEvent arg0) {
		
	}
	@Override
	public void mouseDown(MouseEvent arg0) {
		ml.mouseDown(arg0);
		
	}
	@Override
	public void mouseUp(MouseEvent arg0) {
		ml.mouseUp(arg0);
		
	}
	@Override
	public void mouseMove(MouseEvent arg0) {
		mml.mouseMove(arg0);
		
	}

}
